class RepositoriesController < ApplicationController

	include SendFile

	layout 'standard'

	before_filter :login_required

	def index
		@repositories = Repository.all
	end

	def create
		@repository = Repository.new(params[:repository])

		if @repository.save
			redirect_to repositories_path
		else
			render :action => :new
		end
	end

	def backup
		@repository = Repository.find(params[:id])

		backup = @repository.backup

		xsend_file(backup,
			:disposition => 'inline',
			:encoding => 'utf8',
			:type => 'application/octet-stream',
			:filename => URI.encode("#{@repository.name}.dump"))
	end

	def destroy
		render :nothing => true

		#
		# BLOCKED!
		#
		# @repository = Repository.find(params[:id])
		# @repository.destroy
		# redirect_to repositories_path
	end

end
